package com.kawins.mina.service;

import java.lang.reflect.Method;

import org.springframework.web.bind.annotation.RequestMapping;

import com.kawins.loggers.Loggers;
import com.kawins.mina.core.MethodInvoker;
import com.kawins.mina.core.UriMapping;

/**
 * 所有http请求映射都需要继er Created by think on 2016/1/6.
 */
public abstract class ControllerAdapter extends Loggers {

	public ControllerAdapter() {
		Class<? extends ControllerAdapter> clz = this.getClass();
		Method[] methods = clz.getDeclaredMethods();
		for (int i = 0; i < methods.length; i++) {
			if (methods[i].getAnnotation(RequestMapping.class) != null) {
				log.info(methods[i].getName() + " : " + methods[i].getAnnotation(RequestMapping.class).value()[0]);
				UriMapping.getInstance().put(methods[i].getAnnotation(RequestMapping.class).value()[0],
						new MethodInvoker(this, methods[i]));
			}
		}
	}
}
